<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : categories.xsl
    Created on : March 26, 2013, 4:26 PM
    Author     : duonghung1369
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0" >
    <xsl:output method="html"/>

    <!-- TODO customize transformation rules 
         syntax recommendation http://www.w3.org/TR/xslt 
    -->
    <xsl:template match="/">
<!--        <xsl:apply-templates />
    </xsl:template>
    <xsl:template match="categories">-->
        <table class="data display datatable">
            <thead>
                <tr>
                    <td class="sorting_disable" >Id</td>
                    <td class="sorting_disable" >Name</td>
                    <td class="sorting_disable">Parent Category</td>
                    <td class="sorting_disable" >Deleted</td>
                    <td class="sorting_disable" >Update</td>
                    <td class="sorting_disable" >Delete</td>
                </tr>
            </thead>
            <tbody>
                <xsl:for-each select="categories/category">
                    <xsl:sort select="parent/name" />
                    <form action="../admin/updateCategory.html" method="POST">
                        <tr class="odd">
                            <textarea name="categoryId" style="display:none"><xsl:value-of select="@id" /></textarea>
                            <td id="category-id">
                                <xsl:value-of select="@id" />
                            </td>
                            <td>
                                <xsl:value-of select="name" />
                            </td>
                            <td>
                                <xsl:choose>
                                    <xsl:when test="parent != 'null'">
                                        <xsl:value-of select="parent/name" />
                                    </xsl:when>
                                    <xsl:otherwise>
                                        
                                    </xsl:otherwise>
                                </xsl:choose>
                            </td>
                            <td>
                                <xsl:choose>
                                    <xsl:when test="deleted = 'false'">
                                        <input id="isDeleted" type="checkbox" disabled="disabled" />
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <input id="isDeleted" type="checkbox" checked="true" disabled="disabled" />
                                    </xsl:otherwise>
                                </xsl:choose>
                            </td>
                            <td>
                                <input type="submit" name="btnAction" value="Update" />
                            </td>
                            <td>
                                <xsl:choose>
                                    <xsl:when test="deleted = 'false'">
                                        <input type="button" onclick="deleteCategoryAjax(this);" name="btnAction" value="Hidden" />
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <input type="button" onclick="deleteCategoryAjax(this);" name="btnAction" value="Visible" />
                                    </xsl:otherwise>
                                </xsl:choose>
                                
                            </td>
                        </tr>
                    </form>
                </xsl:for-each>
            </tbody>

        </table>
    </xsl:template>

</xsl:stylesheet>
